package com.dy.createThread;

public class createNewThread {
    public static void main(String[] args) throws InterruptedException {

        System.out.println("main执行开始！");

        //创建新线程
        newThread newThread = new newThread();
        newThread.start();
        //获取当前线程，并让其睡眠1s
        Thread.currentThread().sleep(3000);
        //创建新的线程
        Thread thread = new Thread() {
            public void run() {
                System.err.println("创建线程1");
                System.err.println("创建线程2");
            }
        };
        thread.start();
        System.out.println("main执行结束！");
    }

}
class newThread extends Thread{
    @Override
    public void run(){
        System.out.println("创建新线程！");
    }
}